home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / e / stringnd.lha / stringnode_examples / StringNode_Example2.e < prev    next >
Text File  |  1995-11-07  |  1KB  |  56 lines

  1. /*
  2. ** StringNode Example-2
  3. **
  4. ** add(), del(), first(), succ() AND last() methods.
  5. **
  6. ** (C)Copyright 1995 Fabio Rotondo
  7. **
  8. ** e-mail: fosft@intercom.it
  9. */
  10.  
  11. MODULE 'fabio/StringNode_oo'   -> Our MAGIC MODULE
  12.  
  13. PROC main()
  14.   DEF n:PTR TO stringnode      -> This is our OBJECT instance
  15.  
  16.   NEW n.stringnode()           -> OBJECT initialization
  17.  
  18.   n.add('Zorro')              -> Here we add some items...
  19.   n.add('Batman')
  20.   n.add('Superman')
  21.   n.add('Gold Drake')
  22.   n.add('Mandrake')
  23.   n.add('MOMMY')
  24.  
  25.   shwall(n)                   -> Here we see them
  26.  
  27.   n.first()                   -> This method should be checked agains FALSE...
  28.   n.del()                     -> It is DEAD!
  29.   shwall(n)                   -> Show Results
  30.  
  31.   n.succ()                    -> Two items later... (The first killed...)
  32.   n.del()                     -> Another Kill!
  33.   shwall(n)                   -> Show Results
  34.  
  35.   n.last()                    -> The last item
  36.   n.del()                     -> Is DEAD too!
  37.   WriteF('Last:\s\n', n.name()) -> Now this is the last
  38.   shwall(n)
  39.  
  40.  
  41.   END n                       -> Remember ALWAYS TO end an OBJECT
  42. ENDPROC
  43.  
  44. PROC shwall(n:PTR TO stringnode)
  45.   WriteF('------- \d ----------\n', n.numitems())
  46.  
  47.   IF n.first()                      -> Here we go TO the first node item
  48.     REPEAT
  49.       WriteF('Node:\s\n', n.name()) -> Node STRING...
  50.     UNTIL n.succ() = FALSE          -> LOOP UNTIL the end
  51.   ELSE
  52.     WriteF('No Nodes in LIST...\n')
  53.   ENDIF
  54. ENDPROC
  55.  
  56.